<template>
    <cfg-form-list slot="right">
        <cfg-title-prefix v-bind="config.title" :onlyRead="onlyRead" :data="data"></cfg-title-prefix>
        <cfg-form :only-read="onlyRead" v-bind="config.section.start" :data="data"></cfg-form>
        <cfg-subtitle :title="'投料:'"></cfg-subtitle>
        <cfg-form :onlyRead="onlyRead" style="border:1px solid #dcdee2;padding-top: 10px;" v-bind="config.section.feed" :data="data.feed"></cfg-form>
        <cfg-subtitle :title="'产物:'"></cfg-subtitle>
        <cfg-form :onlyRead="onlyRead" style="border:1px solid #dcdee2;padding-top: 10px;" v-bind="config.section.product" :data="data.product"></cfg-form>
        <cfg-subtitle :title="'记录:'"></cfg-subtitle>
        <cfg-sheet :onlyRead="onlyRead" v-bind="config.section.records" :data="data.records"></cfg-sheet>
        <Button type="primary" long @click="data.records.push({})">加一行</Button>
        <cfg-subtitle :title="'备注:'"></cfg-subtitle>
        <cfg-form :onlyRead="onlyRead" v-bind="config.section.comments" :data="data"></cfg-form>
        <cfg-form :only-read="onlyRead" style="margin-top:10px;" v-bind="config.section.end" :data="data"></cfg-form>
    </cfg-form-list>
</template>

<script>
    export default {
        data () {
            return {
                onlyRead: false,
                config: {
                    title: {
                        title: '生产调度通知书',
                        titleStyle: {},
                        outlineStyle: { marginBottom: '20px' },
                        config: { type: 'text' }
                    },
                    section: {
                        start: {
                            labelWidth: 70,
                            labelPosition: 'right',
                            cols: 4,
                            columns: [
                                { title: '炉号:', key: 'FurnaceNo', config: { type: 'text' } },
                                { title: '表单号:', key: 'formNo', config: { type: 'text' } },
                                { title: '年份:', key: 'year', config: { type: 'select', filterable: true, options: this.getYearOptions() } },
                                { title: '流水号:', key: 'No', config: { type: 'text' } }
                            ],
                            rules: {}
                        },
                        feed: {
                            labelWidth: 70,
                            labelPosition: 'right',
                            cols: 3,
                            columns: [
                                { title: '名称:', key: 'name', config: { type: 'text' } },
                                { title: '批号:', key: 'batchNo', config: { type: 'text' } },
                                { title: '重量:', key: 'weight', config: { type: 'number' } }
                            ],
                            rules: {}
                        },
                        product: {
                            labelWidth: 70,
                            labelPosition: 'right',
                            cols: 2,
                            columns: [
                                { title: '名称:', key: 'name', config: { type: 'text' } },
                                { title: '批次:', key: 'batchNo', config: { type: 'text' } }
                            ],
                            rules: {}
                        },
                        records: {
                            columns: [
                                { title: '管号', align: 'center', key: 'pipeNo', config: { type: 'text' } },
                                { title: '温度 <br/>（摄氏）', align: 'center', key: 'temp', config: { type: 'number' } },
                                { title: '转炉//推速<br/>(HZ//分舟)', align: 'center', key: 'speed', config: { type: 'number' } },
                                { title: '给料转速//装舟量<br/>(HZ//公斤/舟)', align: 'center', key: 'feedSpeed', config: { type: 'text' } },
                                { title: 'H<span style="font-size:12px;font-family:YouYuan">2</span>/H<span style="font-size:12px;font-family:YouYuan">2</span>流量<br/>(m³/h)', align: 'center', key: 'hFlow', config: { type: 'number' } },
                                { title: '出料转速<br/>(HZ)', align: 'center', key: 'dischargeSpeed', config: { type: 'number' } }
                            ]
                        },
                        comments: {
                            labelWidth: 0,
                            labelPosition: 'right',
                            cols: 1,
                            columns: [
                                { title: '', key: 'name', config: { type: 'textarea' } }
                            ],
                            rules: {}
                        },
                        end: {
                            labelWidth: 70,
                            labelPosition: 'right',
                            columns: [
                                { title: '通知者:', key: 'notifier', config: { type: 'text' } },
                                { title: '审核:', key: 'auditor', config: { type: 'text' } },
                                { title: '日期:', key: 'date', config: { type: 'date' } }
                            ],
                            cols: 3,
                            rules: {}
                        }
                    }
                }
            };
        },
        props: {
            data: {
                default: () => {
                    return {
                        titlePrefix: '',
                        FurnaceNo: '',
                        formNo: 'HM-AH032-A',
                        year: '',
                        No: '',
                        feed: {
                            name: '',
                            batchNo: '',
                            weight: 0
                        },
                        product: {
                            name: '',
                            batchNo: ''
                        },
                        records: [
                            {
                                pipeNo: '',
                                temp: 0,
                                speed: 0,
                                feedSpeed: 0,
                                hFlow: 0,
                                dischargeSpeed: 0
                            }
                        ],
                        comments: '',
                        notifier: '',
                        auditor: '',
                        date: ''
                    }
                }
            }
        },
        methods: {
            getYearOptions (startYear = 2022, circle = 100) {
                let options = [];
                for (let index = 0; index < circle; index++) {
                    options.push({ value: startYear + index, label: startYear + index });
                }
                return options;
            }
        }
    };
</script>
<style scoped lang="scss"></style>
